﻿Imports ExternalResource.IconPackage
Imports System.Reflection
Partial Public Class frmMain
#Region "主菜单-文件"
    Const FileFilterText As String = "*.txt(Plain Text Format)|*.txt|*.vb(VisualBasic.Net)|*.vb|" & _
                                     "*.cs(C#)|*.cs|*.xml(XML File)|*.xml|*.html(HTML File)|*.html|*.cob(COBOL)|*.cob|All File|*.*"
    ''' <summary>
    ''' 新建文件
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub File_New()
        If CodeEditor.MainDocument.StepList.UndoStepLength + CodeEditor.MainDocument.StepList.RedoStepLength > 0 Then
            Select Case MsgBox(GetTextInLanguageDoc("SaveFile", TextMode.Text), MsgBoxStyle.Question & MsgBoxStyle.YesNoCancel)
                Case MsgBoxResult.Yes
                    File_Save()
                Case MsgBoxResult.Cancel
                    Exit Sub
            End Select
        End If
        CodeEditor.NewFile(FileEncoding)
        InitMenuAfterNewOrOpenFile()
        Filename = ""
        Me.Text = GetTextInLanguageDoc("NewFile", TextMode.Text) & " - " & Application_Name
    End Sub
    ''' <summary>
    ''' 打开文件
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub File_Open()
        If CodeEditor.MainDocument.StepList.UndoStepLength + CodeEditor.MainDocument.StepList.RedoStepLength > 0 Then
            Select Case MsgBox(GetTextInLanguageDoc("SaveFile", TextMode.Text), MsgBoxStyle.Question & MsgBoxStyle.YesNoCancel)
                Case MsgBoxResult.Yes
                    File_Save()
                Case MsgBoxResult.Cancel
                    Exit Sub
            End Select
        End If
        Using mOpenFileDialog As New OpenFileDialog
            mOpenFileDialog.Filter = FileFilterText
            If mOpenFileDialog.ShowDialog = Windows.Forms.DialogResult.OK Then
                Filename = mOpenFileDialog.FileName
                CodeEditor.LoadFile(Filename, FileEncoding)
                InitMenuAfterNewOrOpenFile()
                Me.Text = Filename & " - " & Application_Name
                DefaultConfig.AddRecentFiles(Filename)
                ResetRecentFile()
            End If
        End Using
    End Sub
    ''' <summary>
    ''' 保存文件
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub File_Save()
        If Filename = "" Then
            Using SaveAs As New SaveFileDialog
                SaveAs.OverwritePrompt = True
                SaveAs.Filter = FileFilterText
                If SaveAs.ShowDialog = Windows.Forms.DialogResult.OK Then
                    Filename = SaveAs.FileName
                    DefaultConfig.AddRecentFiles(Filename)
                    ResetRecentFile()
                End If
            End Using
        End If
        If Filename <> "" Then
            Me.CodeEditor.SaveFile(Filename, FileEncoding)
            Edit_Undo_MenuItem.Enabled = False
            Edit_Undo_ContextMenuItem.Enabled = False
            Edit_Undo_StripButton.Enabled = False
            Edit_Redo_MenuItem.Enabled = False
            Edit_Redo_ContextMenuItem.Enabled = False
            Edit_Redo_StripButton.Enabled = False
            Me.Text = Filename & " - " & Application_Name
        End If
    End Sub
    ''' <summary>
    ''' 另存为
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub File_SaveAs()
        Dim SaveAsFileName As String = String.Empty
        Using SaveAs As New SaveFileDialog
            SaveAs.OverwritePrompt = True
            SaveAs.Filter = FileFilterText
            If SaveAs.ShowDialog = Windows.Forms.DialogResult.OK Then
                SaveAsFileName = SaveAs.FileName
                DefaultConfig.AddRecentFiles(Filename)
                ResetRecentFile()
            End If
        End Using
        If SaveAsFileName <> "" Then
            Filename = SaveAsFileName
            Me.CodeEditor.SaveFile(Filename, FileEncoding)
            Edit_Undo_MenuItem.Enabled = False
            Edit_Undo_ContextMenuItem.Enabled = False
            Edit_Undo_StripButton.Enabled = False
            Edit_Redo_MenuItem.Enabled = False
            Edit_Redo_ContextMenuItem.Enabled = False
            Edit_Redo_StripButton.Enabled = False
            Me.Text = Filename & " - " & Application_Name
        End If
    End Sub
    ''' <summary>
    ''' 新建或者打开文件后的一些菜单复原操作
    ''' </summary>
    ''' <remarks></remarks>
    Sub InitMenuAfterNewOrOpenFile()
        Me.View_ColumnMode_MenuItem.Checked = False
        Me.View_WordWrap_MenuItem.Checked = False
        Me.Edit_ReadOnly_MenuItem.Checked = False
        Edit_Undo_MenuItem.Enabled = False
        Edit_Undo_ContextMenuItem.Enabled = False
        Edit_Undo_StripButton.Enabled = False
        Edit_Redo_MenuItem.Enabled = False
        Edit_Redo_ContextMenuItem.Enabled = False
        Edit_Redo_StripButton.Enabled = False
        Search_PreviousBookMark_MenuItem.Enabled = False
        Search_NextBookMark_MenuItem.Enabled = False
        Search_ClearAllBookMark_MenuItem.Enabled = False
    End Sub
    ''' <summary>
    ''' 设置文件编码
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub SetFileEncoding(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim OrgEncoding As Integer = DefaultConfig.CurrentEncoding
        For Each EncodingItem As ToolStripMenuItem In File_FileEncoding_MenuItem.DropDownItems
            EncodingItem.Checked = False
        Next
        CType(sender, ToolStripMenuItem).Checked = True
        FileEncoding = CType(sender, ToolStripMenuItem).Tag
        Select Case CType(sender, ToolStripMenuItem).Text
            Case EnumEncoding.ANSI.ToString
                DefaultConfig.CurrentEncoding = EnumEncoding.ANSI
            Case EnumEncoding.GB2312.ToString
                DefaultConfig.CurrentEncoding = EnumEncoding.GB2312
            Case EnumEncoding.ShfitJIS.ToString
                DefaultConfig.CurrentEncoding = EnumEncoding.ShfitJIS
            Case EnumEncoding.UTF8.ToString
                DefaultConfig.CurrentEncoding = EnumEncoding.UTF8
        End Select
        WriteObjectToXMLFile(DefaultConfig, GetType(Config), Application.StartupPath & "\Config.xml")
        If OrgEncoding <> DefaultConfig.CurrentEncoding And Not (Filename = "") Then
            If MsgBox(GetTextInLanguageDoc("ReLoadFile", TextMode.Text) & vbCrLf & GetTextInLanguageDoc("ReLoadFileTips", TextMode.Text), _
                      MsgBoxStyle.Question & MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
                CodeEditor.LoadFile(Filename, FileEncoding)
                Me.View_ColumnMode_MenuItem.Checked = False
                Me.View_WordWrap_MenuItem.Checked = False
                Me.Edit_ReadOnly_MenuItem.Checked = False
                Me.Text = Filename & " - " & Application_Name
            End If
        End If
    End Sub
    ''' <summary>
    ''' 页面设置
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub File_PageSetup()
        Dim mPrint As New clsPrint(Me.CodeEditor, mPrintDoc)
        mPrint.PageSetup()
    End Sub
    ''' <summary>
    ''' 打印预览
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub File_PrintPreview()
        Dim mPrint As New clsPrint(Me.CodeEditor, mPrintDoc)
        mPrint.PrintPreView()
    End Sub
    ''' <summary>
    ''' 打印
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub File_Print()
        Dim mPrint As New clsPrint(Me.CodeEditor, mPrintDoc)
        mPrint.Print()
    End Sub
    ''' <summary>
    ''' 重置最近文件列表
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub ResetRecentFile()
        File_RecentFiles_MenuItem.DropDownItems.Clear()
        If DefaultConfig.RecentFiles.Count > 0 Then
            For i As Integer = 0 To DefaultConfig.RecentFiles.Count - 1
                Dim RecentFilesMenuItem As New System.Windows.Forms.ToolStripMenuItem(DefaultConfig.RecentFiles(i))
                File_RecentFiles_MenuItem.DropDownItems.Add(RecentFilesMenuItem)
                AddHandler RecentFilesMenuItem.Click, AddressOf OpenRecentFile
            Next
        End If
    End Sub
    ''' <summary>
    ''' 打开最近文件
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub OpenRecentFile(ByVal Sender As Object, ByVal e As EventArgs)
        If IO.File.Exists(Sender.ToString) Then
            Filename = Sender.ToString
            CodeEditor.LoadFile(Filename, FileEncoding)
            InitMenuAfterNewOrOpenFile()
            Me.Text = Filename & " - " & Application_Name
        End If
    End Sub
    ''' <summary>
    ''' 清除最近文档
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub File_ClearRecentFiles()
        DefaultConfig.ClearRecentFiles()
        ResetRecentFile()
    End Sub
    ''' <summary>
    ''' 退出
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub File_Exit()
        SampleTest_FormClosing(Nothing, Nothing)
        Application.Exit()
    End Sub
#End Region
#Region "主菜单-编辑"
    ''' <summary>
    ''' 矩形选择
    ''' </summary>
    ''' <remarks></remarks>
    Sub Edit_BoxSelect()
        CodeEditor.SwitchBoxSelectMode()
        Me.Edit_BoxSelect_MenuItem.Checked = CodeEditor.BoxSelectMode
        If CodeEditor.BoxSelectMode Then
            Me.View_WordWrap_MenuItem.Enabled = False
            Me.View_WordWrap_MenuItem.Checked = False
            View_ColumnMode_MenuItem.Enabled = False
            View_ColumnMode_MenuItem.Checked = False
        Else
            Me.View_WordWrap_MenuItem.Enabled = True
            View_ColumnMode_MenuItem.Enabled = True
        End If
    End Sub
    ''' <summary>
    ''' 插入时间
    ''' </summary>
    ''' <remarks></remarks>
    Sub Edit_Insert_Time()
        Me.CodeEditor.InsertString(Format(Now, DefaultConfig.TimeFormat))
    End Sub
    ''' <summary>
    ''' 插入日期
    ''' </summary>
    ''' <remarks></remarks>
    Sub Edit_Insert_Date()
        Me.CodeEditor.InsertString(Format(Now, DefaultConfig.DateFormat))
    End Sub
    ''' <summary>
    ''' 只读
    ''' </summary>
    ''' <remarks></remarks>
    Sub Edit_ReadOnly()
        Me.CodeEditor.SwitchReadOnly()
        Me.Edit_ReadOnly_MenuItem.Checked = Me.CodeEditor.ReadOnlyMode
    End Sub
    ''' <summary>
    ''' 撤销
    ''' </summary>
    ''' <remarks></remarks>
    Sub Edit_Undo()
        Me.CodeEditor.UnDo()
        SetUndoRedoUseful()
    End Sub
    ''' <summary>
    ''' 重做
    ''' </summary>
    ''' <remarks></remarks>
    Sub Edit_Redo()
        Me.CodeEditor.Redo()
        SetUndoRedoUseful()
    End Sub
    ''' <summary>
    ''' 重新载入
    ''' </summary>
    ''' <remarks></remarks>
    Sub Edit_ReLoad()
        If Filename <> "" AndAlso IO.File.Exists(Filename) Then
            If CodeEditor.MainDocument.StepList.UndoStepLength + CodeEditor.MainDocument.StepList.RedoStepLength > 0 Then
                Select Case MsgBox(GetTextInLanguageDoc("SaveFile", TextMode.Text), MsgBoxStyle.Question & MsgBoxStyle.YesNoCancel)
                    Case MsgBoxResult.Yes
                        File_Save()
                    Case MsgBoxResult.Cancel
                        Exit Sub
                End Select
            End If
            CodeEditor.LoadFile(Filename, FileEncoding)
            InitMenuAfterNewOrOpenFile()
            Me.Text = Filename & " - " & Application_Name
        End If
    End Sub
    ''' <summary>
    ''' 设置是否可以撤销重做
    ''' </summary>
    ''' <remarks></remarks>
    Sub SetUndoRedoUseful() Handles CodeEditor.UnRedoChanged
        If CodeEditor.MainDocument.StepList.UndoStepLength > 0 Then
            Edit_Undo_MenuItem.Enabled = True
            Edit_Undo_ContextMenuItem.Enabled = True
            Edit_Undo_StripButton.Enabled = True
        Else
            Edit_Undo_MenuItem.Enabled = False
            Edit_Undo_ContextMenuItem.Enabled = False
            Edit_Undo_StripButton.Enabled = False
        End If
        If CodeEditor.MainDocument.StepList.RedoStepLength > 0 Then
            Edit_Redo_MenuItem.Enabled = True
            Edit_Redo_ContextMenuItem.Enabled = True
            Edit_Redo_StripButton.Enabled = True
        Else
            Edit_Redo_MenuItem.Enabled = False
            Edit_Redo_ContextMenuItem.Enabled = False
            Edit_Redo_StripButton.Enabled = False
        End If
    End Sub
#End Region
#Region "主菜单-搜索"
    ''' <summary>
    ''' 查找
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub Search_Find()
        Dim mFind As New dlgFind(Me.CodeEditor)
        mFind.Text = GetTextInLanguageDoc("Find", TextMode.Text)
        mFind.Icon = GetDefaultIcon(ExternalResource.IconPackage.IconType.Search)
        mFind.Show()
    End Sub
    ''' <summary>
    ''' 高亮关键字
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub Search_HeightLight()
        Using mHeightLight As New dlgHeightLight
            mHeightLight.Icon = GetDefaultIcon(ExternalResource.IconPackage.IconType.HeightLight)
            mHeightLight.Text = GetTextInLanguageDoc("HeightLight", TextMode.Text)
            If mHeightLight.ShowDialog = Windows.Forms.DialogResult.OK Then
                Me.CodeEditor.SetHeightLightWord(mHeightLight.strHeightLight)
            End If
        End Using
    End Sub
    ''' <summary>
    ''' 跳转
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub Search_JumpTo()
        Using mJumpTo As New dlgJumpTo
            mJumpTo.Icon = GetDefaultIcon(ExternalResource.IconPackage.IconType.JumpTo)
            mJumpTo.Text = GetTextInLanguageDoc("JumpTo", TextMode.Text)
            mJumpTo.NUDLine.Minimum = 1
            mJumpTo.NUDLine.Maximum = CodeEditor.MainDocument.MaxRealLineNumber
            If mJumpTo.ShowDialog = Windows.Forms.DialogResult.OK Then
                Me.CodeEditor.JumpTo(mJumpTo.LineNumber, mJumpTo.VPosition)
            End If
        End Using
    End Sub
    ''' <summary>
    ''' 设置书签
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub Search_ToggleBookMark()
        If Me.CodeEditor.SwitchBookMark() Then
            Me.Search_PreviousBookMark_MenuItem.Enabled = True
            Me.Search_NextBookMark_MenuItem.Enabled = True
            Me.Search_ClearAllBookMark_MenuItem.Enabled = True
        Else
            Me.Search_PreviousBookMark_MenuItem.Enabled = False
            Me.Search_NextBookMark_MenuItem.Enabled = False
            Me.Search_ClearAllBookMark_MenuItem.Enabled = False
        End If
    End Sub
    Private Sub ResetBookMark(ByVal HasBookMard As Boolean) Handles CodeEditor.BookMarkChanged
        If HasBookMard Then
            Me.Search_PreviousBookMark_MenuItem.Enabled = True
            Me.Search_NextBookMark_MenuItem.Enabled = True
            Me.Search_ClearAllBookMark_MenuItem.Enabled = True
        Else
            Me.Search_PreviousBookMark_MenuItem.Enabled = False
            Me.Search_NextBookMark_MenuItem.Enabled = False
            Me.Search_ClearAllBookMark_MenuItem.Enabled = False
        End If
    End Sub
#End Region
#Region "主菜单-视图"
    ''' <summary>
    ''' 列模式
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub View_ColumnMode()
        Me.CodeEditor.SwitchColumnMode()
        Me.View_ColumnMode_MenuItem.Checked = Me.CodeEditor.ColumnMode
        Me.View_WordWrap_MenuItem.Checked = Me.CodeEditor.WordWrapMode
        If CodeEditor.ColumnMode Then
            View_WordWrap_MenuItem.Enabled = False
            View_WordWrap_MenuItem.Checked = False
            Edit_BoxSelect_MenuItem.Enabled = False
            Edit_BoxSelect_MenuItem.Checked = False
        Else
            View_WordWrap_MenuItem.Enabled = True
            Edit_BoxSelect_MenuItem.Enabled = True
        End If
    End Sub
    ''' <summary>
    ''' 折行显示
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub View_SwitchWordWrap()
        Me.CodeEditor.SwitchWordWrap()
        Me.View_ColumnMode_MenuItem.Checked = Me.CodeEditor.ColumnMode
        Me.View_WordWrap_MenuItem.Checked = Me.CodeEditor.WordWrapMode
        If CodeEditor.WordWrapMode Then
            View_ColumnMode_MenuItem.Enabled = False
            View_ColumnMode_MenuItem.Checked = False
            Edit_BoxSelect_MenuItem.Enabled = False
            Edit_BoxSelect_MenuItem.Checked = False
        Else
            View_ColumnMode_MenuItem.Enabled = True
            Edit_BoxSelect_MenuItem.Enabled = True
        End If
    End Sub
#End Region
#Region "主菜单-工具"
    ''' <summary>
    ''' 转化为HTML页面
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub Tool_Convert2HTML()
        Using mConvertToHTML As New frmConvertToHTML(Me.CodeEditor)
            mConvertToHTML.Text = GetTextInLanguageDoc("ConvertToHTML", TextMode.Text)
            mConvertToHTML.ShowDialog()
            If IO.File.Exists(mConvertToHTML.HTMLFileName) Then
                Try
                    Process.Start(mConvertToHTML.HTMLFileName)
                Catch ex As Exception
                    MsgBox("打开网页异常")
                End Try
            End If
        End Using
    End Sub
    ''' <summary>
    ''' 上色
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub LoadConfig(ByVal sender As System.Object, ByVal e As System.EventArgs)
        For Each LanguageItem As ToolStripMenuItem In Tool_Syntax_MenuItem.DropDownItems
            LanguageItem.Checked = False
            If LanguageItem.ToString = sender.ToString Then LanguageItem.Checked = True
        Next
        Dim CodeConfig As ClsCodeConfig = Nothing
        CodeConfig = ReadObjectFromXMLFile(GetType(ClsCodeConfig), Application.StartupPath & "\CodeConfig\" & sender.ToString & ".xml")
        If CodeConfig IsNot Nothing Then

            '基本
            Me.CodeEditor.SingleLineMinLength = CodeConfig.LeftLimit
            Me.CodeEditor.SingleLineMaxLength = CodeConfig.RightLimit
            Me.CodeEditor.RulerColor = CodeConfig.RulerColor
            Me.CodeEditor.CodeBackColor = CodeConfig.BackColor
            Me.CodeEditor.CodeForeColor = CodeConfig.TextColor
            Me.CodeEditor.SelectionBackColor = CodeConfig.SelectBackColor
            Me.CodeEditor.SelectionForeColor = CodeConfig.SelectTextColor
            '关键字
            Dim AutoFillWordList As New Dictionary(Of String, String)
            AutoFillWordList.Clear()
            Dim tblToolTip As New Dictionary(Of String, String)
            tblToolTip.Clear()
            Dim ColorfulWord As New Dictionary(Of String, Color)
            ColorfulWord.Clear()

            If CodeConfig.KeyWordList.Count > 0 Then
                For Each Key As clsKeyWord In CodeConfig.KeyWordList
                    If Key.Intellisense Then AutoFillWordList.Add(Key.Word, Key.AutoStructure)
                    If Not Key.ToolTips Is String.Empty Then
                        tblToolTip.Add(UCase(Key.Word), Key.ToolTips)
                    End If
                    ColorfulWord.Add(UCase(Key.Word), Key.WordColor)
                Next
            End If
            Me.CodeEditor.WordList = AutoFillWordList
            Me.CodeEditor.ToolTipTable = tblToolTip
            Me.CodeEditor.ColorTable = ColorfulWord
            '注释
            Me.CodeEditor.SingleComment = CodeConfig.SingleCommentMark
            Me.CodeEditor.CommentStart = CodeConfig.BlockCommentStart
            Me.CodeEditor.CommentEnd = CodeConfig.BlockCommentEnd
            Me.CodeEditor.CommentColor = CodeConfig.CommentColor
            '分词
            Me.CodeEditor.DelimitChar = CodeConfig.SplitMark
            '代码折叠
            Me.CodeEditor.ExpandAll()
            Me.CodeEditor.SetSytaxKeyList(CodeConfig.SytaxKeyList)
            Me.CodeEditor.SetSytax()
            Me.CodeEditor.Refresh()
        End If
    End Sub
    ''' <summary>
    ''' 语法设定
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub Tool_SyntaxConfig()
        Dim mCodeConfigDialog As New SyntaxConfigDialog
        mCodeConfigDialog.Icon = ExternalResource.IconPackage.GetDefaultIcon(IconType.SyntaxHeightLight)
        mCodeConfigDialog.Text = GetTextInLanguageDoc("SyntaxConfig_Text", TextMode.Text)
        mCodeConfigDialog.Show()
    End Sub
    ''' <summary>
    ''' 选项
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub Tool_Option()
        Using mOptionDialog As New dlgOption
            mOptionDialog.Icon = ExternalResource.IconPackage.GetDefaultIcon(IconType.Options)
            mOptionDialog.Text = GetTextInLanguageDoc("Option", TextMode.Text)
            mOptionDialog.ShowDialog()
            If mOptionDialog.DialogResult = Windows.Forms.DialogResult.OK Then UseConfig()
        End Using
    End Sub
    ''' <summary>
    ''' 使用反射来动态调用插件
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub LoadPlugIn()
        For Each mFile As String In IO.Directory.GetFiles(Application.StartupPath & "\PlugIn")
            Try
                Dim mAssem As Assembly = Assembly.LoadFile(mFile)
                Dim FileName As String = mFile.Replace(Application.StartupPath & "\PlugIn\", String.Empty)
                Dim mType As Type = mAssem.GetType(Mid(FileName, 1, FileName.Length - 4) & ".PlugIn")
                Dim ConstructorInfo As ConstructorInfo = mType.GetConstructor(New System.Type() {GetType(TextBoxPrj.CodeEditor)})
                Dim mPlug As Object = ConstructorInfo.Invoke(New Object() {Me.CodeEditor})
                '延期绑定
                For Each SubMenu As ToolStripMenuItem In mPlug.GetToolStripMenuItem
                    Me.Tool_MenuItem.DropDownItems.Add(SubMenu)
                Next
                If mPlug.GetContextMenuItem.Count > 0 Then
                    Me.EditorContextMenu.Items.Add("-")
                    For Each SubMenu As ToolStripMenuItem In mPlug.GetContextMenuItem
                        Me.EditorContextMenu.Items.Add(SubMenu)
                    Next
                End If
            Catch ex As Exception

            End Try
        Next
    End Sub
#End Region
#Region "主菜单-帮助"
    ''' <summary>
    ''' 用户手册
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub Help_Userbook()
        If IO.File.Exists(Application.StartupPath & "\MagicEditor.chm") Then
            Process.Start(Application.StartupPath & "\MagicEditor.chm")
        End If
    End Sub
    ''' <summary>
    ''' 关于
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub Help_About()
        Using mAbout As New dlgAbout
            mAbout.Text = GetTextInLanguageDoc("About", TextMode.Text)
            mAbout.Icon = Me.Icon
            mAbout.ShowDialog()
        End Using
    End Sub
#End Region
End Class
